// ignore_for_file: prefer_const_literals_to_create_immutables, prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:cn_flutter_ui/cn_flutter_ui.dart';
import 'package:cn_flutter_ui/vant4.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: '测试',
        theme: ThemeData(
          // This is the theme of your application.
          //
          // Try running your application with "flutter run". You'll see the
          // application has a blue toolbar. Then, without quitting the app, try
          // changing the primarySwatch below to Colors.green and then invoke
          // "hot reload" (press "r" in the console where you ran "flutter run",
          // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the
          // counter didn't reset back to zero; the application is not restarted.
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
            body: MyHomePage(
          title: "555",
        )));
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  Text t = Text("123");
  Widget? w = Container(
    width: 60,
    height: 60,
    color: Colors.yellow,
  );
  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: _body3(),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  String text = "222";
  Widget _body() {
    // return VanBadge(
    //   dot: true,
    //   content: 1,
    //   defaultSlots: Container(
    //     width: 88,
    //     height: 88,
    //     color: Colors.grey,
    //   ),
    // );

    return Column(
      children: [
        // VanBadge(
        //   offset: Offset(0, 0),
        //   content: 0,

        //   // showZero: false,
        //   defaultSlots: Container(
        //     width: 44,
        //     height: 44,
        //     color: Colors.grey,
        //   ),
        //   // contentSlots: w,
        // ),
        // VanButton(
        //   text: "点我",
        //   onTap: () {
        //     setState(() {
        //       text = "1";
        //       w = Container(
        //         width: 20,
        //         height: 20,
        //         color: Colors.green,
        //       );

        //       // w = null;
        //     });
        //   },
        // ),
        // GridView.builder(
        //   physics: NeverScrollableScrollPhysics(),
        //   shrinkWrap: true,
        //   itemCount: 10,
        //   gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        //       crossAxisCount: 3, childAspectRatio: 1),
        //   itemBuilder: (context, index) {
        //     return Container(
        //       alignment: Alignment.bottomCenter,
        //       child: VanBadge(
        //         offset: Offset(0, 0),
        //         content: index * 3,
        //         showZero: false,
        //         defaultSlots: Container(
        //           width: 44,
        //           height: 44,
        //           color: Colors.grey,
        //         ),
        //         // contentSlots: w,
        //       ),
        //     );
        //   },
        // )
      ],
    );
  }

  Widget _body2() {
    return Center(
      child: Container(
        width: 100,
        height: 100,
        color: Colors.blue,
        clipBehavior: Clip.none, // 允许溢出
        child: Stack(
          children: [
            // 容器内容
            Positioned(
              top: 0,
              left: 0,
              child: Container(
                width: 200,
                height: 200,
                child: Text(
                  'Container Content',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),

            // 超出容器范围的子组件
            Positioned(
              // top: -20,
              // right: -20,
              top: 0,
              left: -10,
              child: Container(
                width: 50,
                height: 50,
                color: Colors.red,
                child: Center(
                  child: Text(
                    'Overflow',
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _body3() {
    return ListView(
      children: [
        Row(
          children: [
            // VanButton(
            //   buttonSize: ButtonSize.large,
            //   buttonType: ButtonType.primary,
            //   text: '大',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.normal,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   loadingText: "加载中",
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.small,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.mini,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.large,
            //   buttonType: ButtonType.primary,
            //   loading: false,
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.normal,
            //   buttonType: ButtonType.defaults,
            //   // buttonType: ButtonType.primary,
            //   loading: true,
            //   loadingText: "加载中1s...",
            //   text: '普通按钮',
            //   disabled: true,
            //   icon: VanIcons.add,
            //   onTap: () {},
            // ),

            Expanded(
                child: VanRow(
              wrap: false,
              children: [
                Expanded(
                  child: Text("测试测试测试测试测试测试测试测试测试测试"),
                ),
                Expanded(
                  child: Text("测试测试测试测试测试测试测试测试测试测试"),
                )
              ],
            )),
            // Expanded(
            //     child: Row(
            //   children: [
            //     Expanded(
            //       child: Text("测试测试测试测试测试测试测试测试测试测试"),
            //     ),
            //     Expanded(
            //       child: Text("测试测试测试测试测试测试测试测试测试测试"),
            //     )
            //   ],
            // ))
            // VanRow(
            //   children: [
            //     Text("测试测试测试测试测试测试测试测试测试测试"),
            //     // Text("测试测试测试测试测试测试测试测试测试测试")
            //   ],
            // )

            // VanButton(
            //   buttonSize: ButtonSize.small,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   text: '普通按钮',
            //   loadingText: "加载中...",
            //   disabled: true,
            //   icon: VanIcons.add,
            //   round: true,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.small,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   // disabled: true,
            //   loadingText: "11111222",
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            //   plain: true,
            // ),

            // VanButton(
            //   buttonSize: ButtonSize.mini,
            //   buttonType: ButtonType.primary,
            //   loading: true,
            //   loadingText: "加载中...",
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.small,
            //   buttonType: ButtonType.primary,
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
            // VanButton(
            //   buttonSize: ButtonSize.mini,
            //   buttonType: ButtonType.primary,
            //   text: '普通按钮',
            //   icon: VanIcons.add,
            // ),
          ],
        )
      ],
    );
  }
}
